<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;


class IndexsController extends Controller
{

    /**
     * ActionLogsController constructor.
     * @param $actionLogsService
     */
    public function __construct()
    {

    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $games = Auth::guard('admin')->user()->getGames();

        if (!$request->session()->has('game_id') && count($games) > 0) {
            session(['game_id' => strval(array_keys($games)[0])]);//设置默认game_id
        }

        return view('admin.indexs.index', compact(['games']));
    }

    public function main()
    {
        return view('admin.indexs.main', compact([]));
    }

    public function game(Request $request)
    {
        if ($request->has('game_id')) {
            session(['game_id' => $request->game_id]);
        }

        return redirect('admin/index');
    }

    public function test(Request $request)
    {
        echo 12;
    }
}
